function myfunc(a, b) {
    var a, b;
    return a + b;
}
// console.log(myfunc(2, 3));
// window.console.log(myfunc(2, 3)); 这里不能用window

function myfunc_1() {
    return this;
}
// console.log(myfunc_1);  [Function: myfunc_1] 为什么这里返回的是方法？

var myObject = {
    firstName: "kk",
    lastName: "ii",
    // fullName: function () {
    //     return this.firstName + " " + this.lastName;
    // }
    fullName: function () {
        return this;
    }
}
console.log(myObject.fullName());

//函数构造函数  是一个函数里面再构造一个函数莫？？？？
function myfunc_2(arg1, arg2) {
    this.firstName = arg1;
    this.lastName = arg2;

}
var x = new myfunc_2("ll", "kk");
// console.log(x.firstName);

function myfunc_3(a, b) {
    return a + b;
}
var myObject = myfunc_3.call(myObject, 2, 3);
//console.log(myObject);
console.log();

var myArray_1 = [1, 2];
var myObject_1 = myfunc_3.apply(myObject_1, myArray_1);

//闭包 私有变量是啥？？？
function myfunc_4(a, b) {
    a, b;
    return a + b;
}
// console.log(myfunc_4(2, 3));

var counter = 0;
function add() {
    return counter += 1;
}
// console.log(myfunc_5(counter));
function myfunc_5() {
    return add();
}
// console.log(myfunc_5);

function changetext(id) {
    id.innerHTML = "changes!";
}

function colorChange() {
    style.color = red;
}
//???
// onmouseout onmouseover 通过函数来改变css的样式；
function onmouse() {
    //  document.getElementById(onmousefunc).style.color = "red";

}

//美景
function beautiful() {
    document.getElementById("beautifulAndFruit").src = "imags/4-1.jpg";
}
//水果
function Fruit() {
    document.getElementById("beautifulAndFruit").src = "imags/b-1.jpg";
}

function changeInputBg() {
    document.getElementById("changeInputBg").style.backgroundColor = "pink";
    document.getElementById("changeInputBg").style.borderColor = "red";
}
// 7.19
//使用addEventListenser()方法在按钮中添加点击事件 ???
// document.getElementById("myBtn").addEventListener("click", displayDate);
function displayDate() {
    document.getElementById("demo").innerHTML = Date();
}

// 用 addEventListener方法在按钮中添加点击时间，并弹出框 你好；???用在js里面怎么写呢？
document.getElementById("myBtn_1").addEventListener("click", function () {
    alert("hello world!");
})

// or
function myFunction() {
    alert("hello world");
}

function myFunction_1() {
    alert("Hello world!");
}

function myFunction_2() {
    alert("this is mouseover");
}

function myFunction(p1, p2) {
    return p1 + p2;
}

//js对象
var message = "hello world";
var messageLength = message.length;
console.log(messageLength);

var mesToUpper = message.toUpperCase();
console.log(mesToUpper);

function person(firstname, lastname, age, eyecolor) {
    this.firstname = firstname;
    this.lastname = lastname;
    this.age = age;
    this.eyecolor = eyecolor;

}

//js prototype js原型


//js number 对象 7.20

//7.21 
function myFunction_3() {
    var str = document.getElementById("str_p1").innerHTML;
    var n = str.indexOf("locate");
    document.getElementById("str_p2").innerHTML = n + 1;
}

function myFunction_4() {
    var str_1 = getElementById("str_p3").innerHTML;
    var m = str_1.indexOf("is");
    document.getElementById("str_4").innerHTML = n + 1;
}

//sting
//字符串内容匹配
var str_match = "hello world!";
document.write(str_match.match(world) + '<br>');
document.write(str_match.match(hello) + '<br>');

//字符串中查找字符串
//比如说，想在this is an example.中找到is 出现的位置；
var stringIndexOf = "This is an example.";
console.log(stringIndexOf.indexOf("is"));

//字符替换
function myFunction_5() {
    var str_replace = document.getElementById("demo").innerHTML;
    var txt_replace = str_replace.replace("A", "B");
    document.getElementById("aReplaceB").innerHTML = txt_replace;

}

//字符串转换大小写
var txt = "Hello World!"; //一段字符串变量 string
var txt_up = txt.toUpperCase();
var txt_low = txt.toLowerCase();
console.log(txt_up);

//split 字符串转为数组
var txt_split = "dfghjkldfg";
var txt_douhao = txt_split.split(",");
var txt_space = txt_split.split(" ");
var txt_shugang = txt_split.split("|");

//使用Date()方法获得当前的日期；
//首先创建date()对象
var d = new Date();
var d = new Date(milliseconds);
var d = new Date(dateString);
var d = new Date(year, month, day, hours, minutes, seconds, milliseconds);

//Date()
function myFunction_6() {
    var date = new Date();  //创建了一个date()对象；
    var date_1 = document.getElementById("getYear"); //通过id为getYear找到这个元素（即点击获取年份的元素）
    date_1.innerHTML = date.getFullYear(); //获取这个元素后,通过date()对象获得年份（getFullYear）,把这个元素写入html

}  //当用户点击btn按钮时，获取年份改为此时的年份；

function myFunction_7() {
    // var date_2 = new Date();
    // var date_3 = document.getElementById("serYear");
    // date_3.innerHTML = date_2.setFullYear(1999, 7, 26);

    var date_2 = new Date();
    date_2.setFullYear(1999, 7, 26);
    var date_3 = document.getElementById("setYear");
    date_3.innerHTML = date_2;

}

function myFunction_8() {
    var date_4 = new Date();  //创建一个日期对象；
    var date_5 = document.getElementById("utcToString");
    date_5.innerHTML = date_4.toUTCString();
}

function myFunction_9() {
    var date_6 = new Date();
    var weekday = new Array(7);
    weekday[0] = "周日";
    weekday[1] = "周一";
    weekday[2] = "周二";
    weekday[3] = "周三";
    weekday[4] = "周四";
    weekday[5] = "周五";
    weekday[6] = "周六";
    var date_7 = document.getElementById("getDay");
    date_7.innerHTML = weekday[date_6.getDay()];
}

//html页面显示钟表  ？？？？？为何不显示？？
function myFunction_10() {
    var today = new Date();
    var hour = today.getHours();
    var minute = today.getMinutes();
    var second = today.getSeconds();
    minute = checkTime(minute);
    second = checkTime(second);
    document.getElementById("time").innerHTML = hour + ":" + minute + ":" + second;
    t = setTimeout(function () {
        myFunction_10()
    }, 500);
}

function checkTime(i) {
    if (i < 10) {
        i = "0" + i;
    }
    return i;
}

// 数组对象  失败？？？
var myhouse = new Array();  //新建一个数组对象
myhouse[0] = "keke";
myhouse[1] = "jj";
myhouse[2] = "ff";
var i;
for (i = 0; i < myhouse.length; i++) {
    document.write(myhouse[i] + "<br />");
}

//1. 新建数组，并一个一个的进行赋值，如果有300个数据，那么这样写比较麻烦；
var myhouse = new Array();
myhouse[0] = "keke";
myhouse[1] = "kk";
myhouse[2] = "jk";

//2. 直接把所有的数据写在新建的数组里面；
var myhouse = new Array("keke", "kk", "jk");

//3. 最简单的方法，新建都不用了，直接把数据写在方括号里；
var myhouse = ["keke", "kk", "jk"];

//访问数组里面的数据
var name = myhouse[0];  //访问第一个房子的值，并把它赋值给name变量；
myhouse[0] = "iiii";  //修改了myhouse数组中第一个数组元素的值；

//boolean
var b1 = new Boolean(0);
var b2 = new Boolean(1);
var b3 = new Boolean("kkkk");
var b4 = new Boolean(null);
var b5 = new Boolean(NaN);

//Math()对象
document.write(Math.round(4.7));  //对4.7进行四舍五入；
document.write(Math.random());   //返回一个介于0和1之间的随机数；

//RegExp 对象

//BOM Window
//1.
var w = window.innerWidth;
var h = window.innerHeight;

//2. 
var h_1 = document.documentElement.clientHeight;
var w_1 = document.documentElement.clientWidth;

//3.
var h_2 = document.body.clientHeight;
var w_2 = document.body.clientWidth;

//最实用的js window窗口大小
var w = window.innerWidth; //浏览器窗口内置宽度；
document.documentElement.clientWidth; //文本对象，文本对象元素，客户端宽度
document.body.clientWidth;

var h = window.innerHeight;
document.documentElement.clientHeight
document.body.clientHeight;

window.open(); //打开新窗口；
window.close();  //关闭新窗口；
window.moveTo();  //移动当前窗口
window.resizeTo();  //调整当前窗口；

//window.screen
console.log(screen.availHeight);  //屏幕可用高度
console.log(screen.availWidth); //屏幕可用宽度
console.log(screen.width);    //屏幕的总宽度；
console.log(screen.height);  //屏幕的总高度；
console.log(screen.colorDepth);
console.log(screen.pixelDepth);
console.log(screen.orientation); //屏幕的方向

//window.lacation
console.log(location.href);

function newDoc() {
    window.location.assign("http://www.runoob.com");
}

//window.history.back()
function goBack() {
    window.history.back();
}